package android.tusnotas.receivers;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.tusnotas.activities.CommonActivity;
import android.tusnotas.activities.ShowInstancesActivity;

public class VersionReceiver extends BroadcastReceiver {

	private String activityName;
	private Activity activity;
	
	public VersionReceiver(String activityName, Activity activity){
		this.activityName = activityName;
		this.activity = activity;
	}
	
	@Override
	public void onReceive(Context context, Intent intent) {
		if(this.activity.hasWindowFocus()){
			if (this.activity instanceof CommonActivity){
				CommonActivity ca = (CommonActivity)this.activity;
				ca.askUserForNewAppVersion();
			}else if(this.activity instanceof ShowInstancesActivity){
				ShowInstancesActivity si = (ShowInstancesActivity)this.activity;
				si.askUserForNewAppVersion();
			}
		}
	}

}
